package sync;

public class FileInfo implements Comparable<FileInfo> {

	private String name;
	private long modTime;
	private long fileLength;
	private int windowsHidden; // 1 means that the files attribute is set to hidden in Windows. Otherwise 0.

	public FileInfo(String name, long modTime, long fileLength, int windowsHidden) {

		this.name = name;
		this.modTime = modTime;
		this.fileLength = fileLength;
		this.windowsHidden = windowsHidden;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public long getModTime() {
		return modTime;
	}

	public void setModTime(long modTime) {
		this.modTime = modTime;
	}

	public long getFileLength() {
		return fileLength;
	}

	public void setFileLength(long fileLength) {
		this.fileLength = fileLength;
	}

	public int getWindowsHidden() {
		return windowsHidden;
	}

	public void setWindowsHidden(int windowsHidden) {
		this.windowsHidden = windowsHidden;
	}

	// compares only based on file names
	// if this is later in the alphabet then fileName then the return value i positive
	public int compareTo(FileInfo incomming) {
		return name.compareToIgnoreCase(incomming.getName());
	}

	// if this was later modified then otherModTime, then the return value i positive
	// does not compare folders modtime
	public long compareModTime(long otherModTime, boolean useExactTime) {
		char dirSymbol = name.charAt(name.length()-1); // Gets the last symbol
		if(dirSymbol == '/') {
			return 0L;
		}
		else {
			long calc = this.modTime - otherModTime;
			if(useExactTime == false) {
				if(calc < 2000 && calc > -2000) {
					return 0L;
				}
			}
			return calc;
		}
	}

	public String toString() {
		return name + "\\/" + modTime + "\\/" + fileLength + "\\/" + windowsHidden;
	}

}
